package com.jeesite.modules.dataScreen.enums;

import cn.hutool.core.collection.CollUtil;
import com.jeesite.modules.dataScreen.web.vo.IndustryIndexVo;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import static com.jeesite.modules.dataScreen.web.vo.IndustryIndexVo.Range.of;
import static com.jeesite.modules.dataScreen.web.vo.IndustryIndexVo.Range;
import static com.jeesite.modules.dataScreen.web.vo.IndustryIndexVo.Range.MAX_VAL;
import static com.jeesite.modules.dataScreen.web.vo.IndustryIndexVo.Range.MIN_VAL;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Slf4j
@Getter
public enum IndustryIndexColorEnum {

    GL_REPAIR_RATE("公路阻断事件抢通率", of("0", "80", Color.RED), of("100", MAX_VAL, Color.RED)),
    GS_REPAIR_RATE("高速公路阻断事件抢通率", of("0", "80", Color.RED), of("100", MAX_VAL, Color.RED)),
    GL_BRIDGE_HEALTH("公路重大桥梁实时监测健康率"),
    GS_RESCUE_30("高速公路救援车辆30分钟到达率", of("0", "60", Color.RED), of("60", "70", Color.YELLOW), of("70", "90", Color.RED)),
    PTGS_INTERDICT("普通国省道阻断事件抢通率", of("0", "80", Color.RED), of("100", MAX_VAL, Color.RED)),
    TL_WC_INVEST("当年累计完成投资率"),
    MH_UNSECURE_NUM("江北机场净空不安全事件发生数量", of("1", MAX_VAL, Color.RED)),
    GH_CONTAMINATE("船舶水污染物接收转运率", of("0", "40", Color.RED), of("40", "60", Color.ORANGE), of("60", "80", Color.YELLOW)),
    GH_SCRAP("运输船舶强制报废预警数", of("10", "30", Color.YELLOW), of("30", "50", Color.ORANGE), of("50", MAX_VAL, Color.RED)),
    GH_SCRAP_CREDENTIAL("船舶检验证书到期预警数"),
    DLYS_TAXI_R_C("火车站出租汽车候车乘客人车比（西站）"),
    SLHY_LJKY("两江游乘客数预警指数（西站）", of("100", "140", Color.YELLOW), of("140", "180", Color.ORANGE), of("180", MAX_VAL, Color.RED)),
    SLHY_SXKY("三峡游乘客数预警指数（西站）", of("100", "150", Color.YELLOW), of("150", "200", Color.ORANGE), of("200", MAX_VAL, Color.RED)),
    ZH_JTYS_CONCLUDE("全市实时\"货车超限违法行为溯源\"多跨事件办结率", of("100", MAX_VAL, Color.YELLOW)),
    ZH_JTYS_CX("全市实时重点货运源头单位货车超限率", of(MIN_VAL, MAX_VAL, Color.RED)),
    ZH_JTYS_BDW("全市实时非现场治超百吨货车预警数", of("1", MAX_VAL, Color.RED)),
    ZH_JTYS_FXCXC_100("全市实时非现场治超超限100%货车预警数", of("1", MAX_VAL, Color.RED)),
    ZH_JTYS_JSYJKD_100("全市实时道路危货运输驾驶员健康度", of("0", "95", Color.RED)),
    ZH_JTYS_CARJKD_100("全市实时道路危货运输车辆健康度", of("0", "90", Color.RED)),
    ZH_JTYS_COMJKD_100("全市实时道路危货运输企业健康度", of("0", "90", Color.RED)),

    //高速铁路路网密度
    GS_RAILWAY_DENSITY("", of("0", "22", "red"), of("22", "100", "green")),

    //铁路投资完成率（阈值为1季度20%，2季度40%，3季度70%，4季度100%）
    DNLJWCTZ("当年累计完成投资", of("70", "100", Color.RED)),
    //民航投资完成率（阈值为1季度25%，2季度50%，3季度75%，4季度100%）
    MHDNZJXMTZWCL("民航当年在建项目投资完成率", of("70", "100", Color.RED)),
    CSGDJTKYFDL("城市轨道交通客运分担率", of("60", "100", Color.RED)),
    QSSSDLWHYSJSYJKD("全市实时道路危货运输驾驶员健康度", of("80", "100", Color.RED)),
    QSSSDLWHYSCLJKD("全市实时道路危货运输车辆健康度", of("80", "100", Color.RED)),
    QSSSDLWHYSQYJKD("全市实时道路危货运输企业健康度", of("80", "100", Color.RED)),
    QSDQDLWHYSAQYHJCL("全市当前道路危货运输安全隐患解除率", of("65", "100", Color.RED)),
    DNTLZDGCXMJHTZ("当年铁路重点工程项目计划投资", of("50", "100", "red")),
    CSGGJTJDHCXFDL("城市公共交通机动化出行分担率", of("58", "100", Color.RED)),

    HYZL_HDLL_WL("航道流量（武隆）", of("6000", "15000", Color.YELLOW), of("15000", "30000", Color.ORANGE), of("30000", MAX_VAL, Color.RED)),
    HYZL_HDLL_CT("航道流量（寸滩）", of("6000", "15000", Color.YELLOW), of("15000", "30000", Color.ORANGE), of("30000", MAX_VAL, Color.RED)),
    HYZL_HDLL_BBS("航道流量（北碚三）", of("6000", "8000", Color.YELLOW), of("8000", "18000", Color.ORANGE), of("18000", MAX_VAL, Color.RED)),
    HYZL_HDSW_WL("航道水位（武隆）", of("0", "169.35", Color.YELLOW)),
    HYZL_HDSW_CT("航道水位（寸滩）", of("0", "158.82", Color.YELLOW)),
    HYZL_HDSW_BBS("航道水位（北碚三）", of("0", "173.43", Color.YELLOW)),

    ;

    private final String name;

    private final List<IndustryIndexVo.Range> ranges;

    final static Map<String, List<Range>> cache = new ConcurrentHashMap<>();


    static {
        for (IndustryIndexColorEnum value : values()) {
            cache.put(value.getName(), value.getRanges());
        }
    }

    interface Color {
        String RED = "#fb1100";
        String ORANGE = "#FF9800";
        String YELLOW = "#ffeb3b";
        String BLUE = "#50B7FF";
    }

    IndustryIndexColorEnum(String name, Range... ranges) {
        this.name = name;
        this.ranges = CollUtil.toList(ranges);
    }

    public static List<Range> getRange(String name) {
        return cache.get(name);
    }
}
